/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.thienloc.omap.util;

/**
 *
 * @author GiangLT
 */
public abstract class AbstractRunnable implements Runnable {

    /**
     *
     */
    protected String name;

    /**
     *
     * @return
     */
    public String getName() {
        return name;
    }

    /**
     *
     * @param name
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     *
     * @param name
     */
    public AbstractRunnable(String name) {
        this.name = name;
    }

//    @Override
    public void run() {
        try {
            onExecuting();
            action();
        } catch (Exception ex) {
            onException(ex);
        }
        onKilling();
    }

    /**
     *
     */
    protected abstract void action();

    /**
     *
     */
    protected abstract void onExecuting();

    /**
     *
     * @param ex
     */
    protected abstract void onException(Exception ex);

    /**
     *
     */
    protected abstract void onKilling();
}
